<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>你的小家，我的大事</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <link href="css/button.css" rel="stylesheet" type="text/css" />
    <link href="css/icon.css" rel="stylesheet" type="text/css" />
    <link href="css/evaluate.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <div class="container">
        <div class="star-bar">总分
            <i class="icon icon-star-blank"></i>
            <i class="icon icon-star-blank"></i>
            <i class="icon icon-star-blank"></i>
            <i class="icon icon-star-blank"></i>
            <i class="icon icon-star-blank"></i>
        </div>
        <textarea name="content" rows="6" placeholder="服务温柔吗？颜值够高吗？小家温暖吗？（至少写够15个字，证明你是走心不是走肾哦哈哈！）"></textarea>
        <div class="check">
            <i class="icon icon-dot-blank"></i> 匿名评价
        </div>
        <div id="container" class="image-container">
            <div id="pickfile" class="image-item">
                上传图片
            </div>
        </div>
    </div>
    <button class="btn btn-submit sbm yellow comment">立即评价</button>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
    <script src="js/template.js" type="text/javascript"></script>
    <script src="js/plupload.full.min.js" type="text/javascript"></script>
    <script src="js/qiniu.min.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            bee.wxConfig(function() {
                bee.hideAllNonBaseMenuItem();
            }, function(res) {});

            bee.request({
                url: '/Index/Index/get_qiniu',
                data: null,
                success: function(result) {
                    var uploader = Qiniu.uploader({
                        runtimes: 'html5,flash,html4',
                        browse_button: 'pickfile',
                        container: 'container',
                        drop_element: 'container',
                        max_file_size: '100mb',
                        flash_swf_url: 'swf/Moxie.swf',
                        dragdrop: true,
                        chunk_size: '4mb',
                        uptoken: result.token,
                        domain: 'sugray.com',
                        auto_start: true,
                        // unique_names: false,
                        // save_key: false,
                        init: {
                            'FileUploaded': function(up, file, info) {
                                info = JSON.parse(info);
                                $('#pickfile').before('<img src="' + bee.link.image + '/' + info.key + '?imageView2/1/w/80/h/80" />');
                            },
                            'Key': function(up, file) {
                                var key = new Date().getTime();
                                return key;
                            }
                        }
                    });
                }
            });

            $('body').on('click', '.check .icon', function() {
                if ($(this).hasClass('icon-dot-blank')) {
                    $(this).removeClass('icon-dot-blank').addClass('icon-dot');
                } else {
                    $(this).removeClass('icon-dot').addClass('icon-dot-blank');
                }
            });

            $('body').on('click', '.star-bar .icon', function() {
                $(this).prevAll().removeClass('icon-star-blank').addClass('icon-star');
                $(this).nextAll().removeClass('icon-star').addClass('icon-star-blank');
                $(this).removeClass('icon-star-blank').addClass('icon-star');
            });

            $('body').on('click', '.sbm', function() {
                var star = $('.star-bar .icon-star').length;
                var content = $('[name="content"]').val();
                var anonymous = $('.check .icon-star').length;
                var pic = [];
                $('.image-container img').each(function() {
                    pic.push($(this).attr('src').split('?')[0]);
                });

                bee.request({
                    url: '/Member/Index/comment_add',
                    data: {
                        housekeeper_id: bee.getQueryString('id'),
                        star: star,
                        content: content,
                        anonymous: anonymous,
                        pic: pic.join(',')
                    },
                    success: function(result) {
                        bee.open('comment.html', {
                            id: bee.getQueryString('id')
                        });
                    }
                });
            });
        });
    </script>
</body>

</html>
